home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Online / opennap / ping.c < prev    next >
C/C++ Source or Header  |  2001-06-08  |  1KB  |  55 lines

  1. /* Copyright (C) 2000-1 drscholl@users.sourceforge.net
  2.    This is free software distributed under the terms of the
  3.    GNU Public License.  See the file COPYING for details.
  4.  
  5.    $Id: ping.c,v 1.12 2001/02/15 08:39:45 drscholl Exp $ */
  6.  
  7. #include <string.h>
  8. #include "opennap.h"
  9. #include "debug.h"
  10.  
  11. /* [ :<user> ] <user> [ <optional args> ] */
  12. HANDLER (ping)
  13. {
  14.     USER *orig, *user;
  15.     char *nick;
  16.  
  17.     (void) len;
  18.     ASSERT (validate_connection (con));
  19.  
  20.     if (pop_user (con, &pkt, &orig) != 0)
  21.     return;
  22.     nick = pkt;
  23.     pkt = strchr (nick, ' ');
  24.     if (pkt)
  25.     *pkt++ = 0;
  26.  
  27.     user = hash_lookup (Users, nick);
  28.     if (!user)
  29.     {
  30.     if (ISUSER (con))
  31.     {
  32.         send_cmd (con, MSG_SERVER_NOSUCH, "ping failed, %s is not online",
  33.               nick);
  34.     }
  35.     return;
  36.     }
  37.  
  38.     if (ISUSER (user->con))
  39.     {
  40.     if (!is_ignoring (user->con->uopt->ignore, orig->nick))
  41.         send_cmd (user->con, tag, "%s%s%s", orig->nick, pkt ? " " : "",
  42.               NONULL (pkt));
  43.     else
  44.         send_user (orig, MSG_SERVER_NOSUCH, "%s is ignoring you",
  45.                user->nick);
  46.     }
  47.     else
  48.     {
  49.     /* send the message to the server which this user appears to be
  50.        behind */
  51.     send_cmd (user->con, tag, ":%s %s%s%s", orig->nick, user->nick,
  52.           pkt ? " " : "", NONULL (pkt));
  53.     }
  54. }
  55.